<?php
// +----------------------------------------------------------------------
// | ThinkPHP [ WE CAN DO IT JUST THINK ]
// +----------------------------------------------------------------------
// | Copyright (c) 2006-2016 http://thinkphp.cn All rights reserved.
// +----------------------------------------------------------------------
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
// +----------------------------------------------------------------------
// | Author: 流年 <liu21st@gmail.com>
// +----------------------------------------------------------------------

// 应用公共文件
/**
 * 递归重新排序无限级分类数组
 */

 function recursive($array,$pid=0,$level=0)
{
    $arr=array();
    foreach ($array as $v)
    {
        if($v['pid'] == $pid )
        {
        	$v['level']=$level;
        	$v['html']=str_repeat('--',$level);
            $arr[]=$v;
            $arr=array_merge($arr,recursive($array,$v['id'],$level+1));
        }            
    }
    return $arr;
}
/**
 * 获取传递ID的所有子分类ID
 */

function get_all_child($array,$id)
{
  $arr=array();
  foreach($array as $v)
  	if($v['pid']==$id)
  	{
  		$arr[]=$v['id'];
  		$arr=array_merge($arr,get_all_child($arr,$v['pid']));
  	}
  	return $arr;
}
